import { post, get, postFormData } from "./api.js";

//发送验证码（登录）
export const slidingVerifyApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/slidingVerify", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//发送验证码（登录）
export const sendVerificationCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/sendVerifyCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//发送验证码（注册）
export const sendRegisterVerifyCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/sendRegisterVerifyCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//发送验证码（忘记密码）
export const sendFindpwdVerifyCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/sendFindpwdVerifyCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//用户手机验证码登录
export const userLoginByPwdApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/loginByPwd", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//用户账号密码登录
export const userLoginApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/login", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//找回密码
export const setNewpwdApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/setNewpwd", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//用户注册
export const userRegisterApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/register", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//用户认证
export const userAuthApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/userAuth", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//获取用户信息
export const getUserInfoApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/userCenter", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//获取点赞列表
export const getMyLikesListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/myLikesList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//获取收藏列表
export const getMyCollectListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/myCollectList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//获取当前拥有列表
export const getMyOrderListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/myOrderList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//取消点赞
export const resetLikesApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/resetLikes", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//取消收藏
export const resetCollectApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/resetCollect", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//修改个人资料
export const updateProfileApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/updateProfile", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//上传头像
export const uploadAvatarApi = params =>
  new Promise((resolve, reject) => {
    postFormData("api/client/user/uploadAvatar", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品分类
export const getGoodsCatesApi = params =>
  new Promise((resolve, reject) => {
    post("/api/client/goods/goodsCates", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品专辑
export const getGoodsAlbumApi = params =>
  new Promise((resolve, reject) => {
    post("/api/client/goods/goodsAlbum", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//首页推荐商品
export const getRecommendGoodsApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/recommendGoods", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//banner列表
export const getBannerListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/banner/getBannerList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品列表
export const getDoodsListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/goodsList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品详情
export const getGoodsInfoApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/collectionsInfo", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品详情
export const getOrderInfoApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/orderInfo", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品详情（相关商品）
export const getSimilarGoodsListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/similarGoodsList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品点赞
export const doLikesApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/doLikes", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//商品收藏
export const doCollectApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/doCollect", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//专辑列表
export const getGoodsAlbumListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/goodsAlbum", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//创建订单
export const createOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/order/createOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//支付结算页面
export const payOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/order/payOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//统一下单支付
export const unifiedOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/pay/unifiedOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//微信公众号支付下单
export const UnifiedWxJSApiOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/pay/unifiedWxOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//支付宝支付下单
export const unifiedAplipayOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/pay/unifiedAplipayOrder ", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//连连统一创单
export const tradeCreateApi = params =>
  new Promise((resolve, reject) => {
    post("api/lianlianpay/tradeCreate", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
//连连预支付
export const paymentBankcardApi = params =>
  new Promise((resolve, reject) => {
    post("api/lianlianpay/payment_bankcard", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
//连连确认支付
export const verifySmsApi = params =>
  new Promise((resolve, reject) => {
    post("api/lianlianpay/verifySms", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//初始化config
export const wxPayConfigApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/wxPayConfig", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//检测订单是否已经支付
export const checkOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/checkOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取合作伙伴
export const getPartnerListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/partnerList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// weixin
export const wxOAuthApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/wxOAuth", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 生成微信登录二维码
export const wxQrcodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/wxQrcode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 定时检测用户是否扫码登录
export const checkWxScanLoginApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/checkWxScanLogin", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 绑定手机号
export const bindPhoneApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/bindPhone", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 移动端微信登录
export const wxLoginApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/wxLogin", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 藏品转赠
export const transferTokenApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/transferToken", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
// 检测转赠的钱包地址是否为本商城的用户
export const checkTransferUserApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/checkTransferUser", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 转赠给我的nft列表
export const transferOrderListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/transferOrderList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 搜索联想
export const associateSearchApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/goods/associateSearch", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//邀请页面
export const inviteApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/invite", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//邀请记录
export const inviteRecordApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/inviteRecord", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//邀请好友开启盲盒
export const luckDrawPrizeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/luckDrawPrize", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 公告
export const noticeInfoApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/noticeInfo", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
// 银行卡信息查询
export const bankcardInfoApi = params =>
  new Promise((resolve, reject) => {
    post("api/easyPay/bankcardInfo", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
// 预支付
export const advancePayApi = params =>
  new Promise((resolve, reject) => {
    post("api/easyPay/advancePay", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
// 确认支付
export const doPayApi = params =>
  new Promise((resolve, reject) => {
    post("api/easyPay/doPay", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
//收银台下单
export const cashierPayApi = params =>
  new Promise((resolve, reject) => {
    post("api/cashier/cashierPay", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//开启权限
export const openprizeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/openprize", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取代金券兑换列表
export const exchangeListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/coupon/exchangeList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 兑换代金券
export const doExchangeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/coupon/doExchange", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取支付页面代金券列表
export const getAvailableCouponApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/coupon/getAvailableCoupon", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//获取一元购列表
export const getGoodsOnebuyListApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/onebuy/getGoodsOnebuyList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//创建一元购订单
export const createOneOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/onebuy/createOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

//一元购邀请好友生成二维码
export const createOneBuyCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/onebuy/createOneBuyCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取公告历史
export const noticeRecordApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/noticeRecord", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取二维码
export const paySuccessCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/liveCode/paySuccessCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 检测一元购邀请码是否有效
export const verifyOneBuyCodeApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/user/verifyOneBuyCode", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 取消订单
export const resetOrderApi = params =>
  new Promise((resolve, reject) => {
    post("api/client/order/resetOrder", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取碎片列表
export const myPieceApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/myPiece", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取碎片详情
export const myPieceDetailApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/myPieceDetail", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取转赠记录
export const transforeRecordApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/transforeRecord", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 转赠
export const transforeApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/transfore", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取合成记录
export const getRecordApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/getRecord", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取合成藏品列表
export const getListApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/getList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取合成详情
export const getDetailApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/getDetail", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 合成
export const doComposeApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/doCompose", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 购买后获得碎片
export const getPieceSuccessApi = params =>
  new Promise((resolve, reject) => {
    post("api/userCompose/getPieceSuccess", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });

// 获取勋章列表
export const getInviteListApi = params =>
  new Promise((resolve, reject) => {
    post("api/invite/getInviteList", params)
      .then(res => {
        resolve(res.data);
      })
      .catch(err => {
        reject(err.data);
      });
  });
